package com.own.component.store.local;

import com.own.component.store.core.DefaultStore;
import com.own.component.store.core.property.StoreProperty;
import com.own.component.store.local.method.DefaultLocalStoreAtomic;
import com.own.component.store.local.method.DefaultLocalStoreList;
import com.own.component.store.local.method.DefaultLocalStoreMap;
import com.own.component.store.local.method.DefaultLocalStoreSet;
import com.own.component.store.local.method.DefaultLocalStoreValue;

/**
 * DefaultLocalStore
 * <p>
 * 使用本地缓存技术
 *
 * @author chenxueli
 * @date 2022-06-15 03:14:15
 */
public class DefaultLocalStore<T> extends DefaultStore<T> {

    /**
     * 不设置定时清除的方法（不建议）
     */
    public DefaultLocalStore() {
        super(
                new DefaultLocalStoreValue<>(),
                new DefaultLocalStoreMap<>(),
                new DefaultLocalStoreSet<>(),
                new DefaultLocalStoreList<>(),
                new DefaultLocalStoreAtomic()
        );
    }

    /**
     * 设置定时清除的方法
     *
     * @param properties 配置
     */
    public DefaultLocalStore(StoreProperty properties) {
        super(
                new DefaultLocalStoreValue<>(properties.getValue() == null ? properties : properties.getValue()),
                new DefaultLocalStoreMap<>(properties.getMap() == null ? properties : properties.getMap()),
                new DefaultLocalStoreSet<>(properties.getSet() == null ? properties : properties.getSet()),
                new DefaultLocalStoreList<>(properties.getList() == null ? properties : properties.getList()),
                new DefaultLocalStoreAtomic(properties.getAtomic() == null ? properties : properties.getAtomic())
        );
    }

}
